package com.lee.lease.web.app.controller.apartment;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lee.lease.common.result.Result;
import com.lee.lease.web.app.service.RoomInfoService;
import com.lee.lease.web.app.vo.room.RoomDetailVo;
import com.lee.lease.web.app.vo.room.RoomItemVo;
import com.lee.lease.web.app.vo.room.RoomQueryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * ClassName: RoomController
 * Package: com.lee.lease.web.app.controller.apartment
 * Description:
 */
@RestController
@RequestMapping("/app/room")
@Tag(name = "房间信息")
public class RoomController {


    @Autowired
    private RoomInfoService service;

    @Operation(summary = "分页查询房间列表")
    @GetMapping("pageItem")
    public Result<IPage<RoomItemVo>> getRoomItems(Integer current, Integer size, RoomQueryVo queryVo){
        IPage<RoomItemVo> page = new Page<>(current,size);
        IPage<RoomItemVo> pageInfo = service.findRoomItem(page,queryVo);
        return Result.ok(pageInfo);
    }
    @Operation(summary = "根据公寓id分页查询房间列表")
    @GetMapping("/pageItemByApartmentId")
    public Result<IPage<RoomItemVo>> getRoomItemsByApartmentId(Integer current, Integer size, Integer id){
        IPage<RoomItemVo> page = new Page<>(current,size);
        IPage<RoomItemVo> pageInfo = service.findRoomItemByApartmentId(page,id);
        return Result.ok(pageInfo);
    }

    @Operation(summary = "根据id获取房间的详情")
    @GetMapping("/getDetailById")
    public Result<RoomDetailVo> getDetailById(Integer id){
        //房间存在
        //房间不存在
        RoomDetailVo roomDetailVo = service.getDetailById(id);
        return Result.ok(roomDetailVo);
    }
    @Operation(summary = "根据id获取房间的详情1")
    @GetMapping("/getDetailById1")
    public Result<RoomDetailVo> getDetailById1(Integer id){
        //房间存在
        //房间不存在
        RoomDetailVo roomDetailVo = service.getDetailById1(id);
        return Result.ok(roomDetailVo);
    }


}
